<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use app\common\library\Auth;
use app\model\Admin;
use app\model\Category;
use Dompdf\Dompdf;
use Dompdf\Options;

class Index extends Frontend
{
    protected $layout = '';
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';


    public function index()
    {
        $url = request()->domain()."/admin.php";
        header("location:$url");
        die();
        $is_mobile = is_mobile_request();
        if($is_mobile){
           /* $host = $_SERVER['HTTP_HOST'];
            $host = str_replace("yueke.",'',$host);

            $host = $_SERVER['HTTP_HOST'];
            $hostArr = explode('.',$host);
            if(count($hostArr) == 3){
                $hostArr[0] = 'h5';
            }else{
                array_unshift($hostArr,'h5');
            }
            $host =implode('.',$hostArr);
            if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
                $url = "https://".$host;
            } else {
                $url = "http://".$host;
            }*/
            $url = request()->domain()."/mobile";
            header("location:$url");
        }else{

        }
        $this->view->assign('is_mobile',$is_mobile == true ? '1' : 0);

        return $this->view->fetch();
    }


    public function ceshi(){

        $content = $this->view->fetch();
//        echo $content;die();
        $options = new Options();
        $options->set('isHtml5ParseEnabled',true);
        $options->set('isRemoteEnabled',true);
        $dompdf = new Dompdf($options);

        $dompdf->loadHtml($content);
        $dompdf->setPaper('A4','portrait');
        $dompdf->render();
        $dompdf->stream(RUNTIME_PATH."11.pdf",['Attachment'=>0]);
//        file_put_contents(RUNTIME_PATH."11.pdf",$dompdf->output());
        ppd(22);
    }
}
